package com.leetcode;

import java.util.Scanner;

/**
 * TODO
 *
 * @author lefly
 * @version 1.0
 * @classname No504
 * @description
 * @date 2021/2/7 下午1:05
 */
public class No504 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        String res = convertToBase7(num);
        System.out.println(res);

    }

    public static String convertToBase7(int num) {
        boolean isNeg = num < 0;
        num = Math.abs(num);
        StringBuilder str = new StringBuilder();
        while (num != 0){
            str.append(num % 7);
            num /= 7;
        }
        return isNeg ? ("-" + str.reverse()).toString() : str.reverse().toString();
    }

}
